When PropertyValue "parameters" is [null] or [EMPTY], return to HashMap that can be modified#12354
Merged
AlbumenJ merged 2 commits intoapache:3.2from May 21, 2023
Merged
Conversation
AlbumenJ
requested changes
May 19, 2023
Member
AlbumenJ
left a comment
There was a problem hiding this comment.
BTW, pls replace the PR subject as a considerable one and comment in English.
| import java.util.Collections; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
| import java.util.*; |
Member
There was a problem hiding this comment.
Please do not use comma import
| public static Map<String, String> convertParameters(String[] parameters) { | ||
| if (ArrayUtils.isEmpty(parameters)) { | ||
| return Collections.emptyMap(); | ||
| return new HashMap<>(); |
Member
There was a problem hiding this comment.
Null return in org.apache.dubbo.config.AbstractMethodConfig#getParameters is also need to be considered
…eters中put对象为空时,返回空的HashMap而不是EmptyMap以支持后续put
797ed4b to
8270187
Compare
AlbumenJ
requested changes
May 19, 2023
|
|
||
| public Map<String, String> getParameters() { | ||
| return parameters; | ||
| this.parameters = Optional.ofNullable(parameters).orElseGet(HashMap::new); |
Member
There was a problem hiding this comment.
Set the newly created map to this.
|
Kudos, SonarCloud Quality Gate passed! |
AlbumenJ
approved these changes
May 21, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.








org.apache.dubbo.config.spring.util.DubboAnnotationUtils.convertParametersWhen the
puttarget is an empty String array, the emptyHashMapinstead ofjava.util.Collections.EmptyMapsupports subsequent scalableputoperations org.apache.dubbo.config.spring.util.DubboAnnotationUtils#convertParameters中当参数列表未空时,直接返回了不可修改的Collections.emptyMap(),我认为不合适 #12350What is the purpose of the change
So that
@DubbboService#parameter, even if empty, does not affect the extra put operation causing the program to throw an exception---->
Collections.emptyMap()is a special implementation of EmptyMap inside Collections that doesn't support change, so I don't think it makes any sense to set a Map of that type hereorg.apache.dubbo.config.AbstractMethodConfig#getParametersPrevents this function from returning null
---->
Verifying this change
......